Skip to content

PR: Gap fill 1 - Missing types (DiffMode, BlackListConfig, DownloadAsset, PacketDTO, MacStrategy) - #335

Merged
JusterZhu merged 2 commits into
masterfrom
feat/missing-types
May 24, 2026
Merged

JusterZhu merged 2 commits into
masterfrom
feat/missing-types

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

Closes #334. 10 new files — filling types gap from plan-vs-implementation audit.

Files

File Description
\Configuration/DiffMode.cs\ DiffMode enum (Serial/Parallel)
\Configuration/HubConfig.cs\ HubConfig class
\Configuration/BlackListConfig.cs\ BlackListConfig record + Empty
\Download/Models/DownloadAsset.cs\ DownloadAsset + DownloadPlan records
\Download/Abstractions/IDownloadSource.cs\ IDownloadSource + IDownloadPipeline
\Download/Abstractions/PacketDTO.cs\ PacketDTO + VersionRequest/Response
\Download/Pipeline/DefaultDownloadPipeline.cs\ SHA256 verify pipeline
\Download/Progress/DownloadProgressReporter.cs\ IProgress-Event bridge
\Download/Executors/OssDownloadExecutor.cs\ OSS download executor
\Strategy/MacStrategy.cs\ macOS update strategy

Build

✅ 0 errors

…g, DownloadAsset, PacketDTO, MacStrategy

- DiffMode enum (Serial/Parallel)
- HubConfig (Url, ReconnectDelay, MaxReconnectAttempts)
- BlackListConfig record (BlackFiles/BlackFormats/SkipDirectorys + Empty)
- DownloadAsset + DownloadPlan records (with cross-version fields)
- IDownloadSource + IDownloadPipeline interfaces
- PacketDTO + VersionRequest + VersionResponse server contracts
- DefaultDownloadPipeline (SHA256 verify)
- DownloadProgressReporter (IProgress to event bridge)
- OssDownloadExecutor (OSS HTTP download)
- MacStrategy (macOS update strategy)

Closes #334
Copilot AI review requested due to automatic review settings May 24, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fills in several missing Core types identified by the plan-vs-implementation audit (issue #334), primarily around download abstractions/models and platform strategy support.

Changes:

  • Adds new configuration types (DiffMode, HubConfig, BlackListConfig).
  • Introduces a download model/abstraction surface (DownloadAsset/DownloadPlan, IDownloadSource/IDownloadPipeline, PacketDTO contracts) plus basic implementations (SHA256 pipeline, OSS executor, progress reporter).
  • Adds a new macOS strategy implementation (MacStrategy).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/c#/GeneralUpdate.Core/Strategy/MacStrategy.cs Adds a macOS strategy class.
src/c#/GeneralUpdate.Core/Download/Progress/DownloadProgressReporter.cs Adds an adapter from IProgress<DownloadProgress> to callbacks.
src/c#/GeneralUpdate.Core/Download/Pipeline/DefaultDownloadPipeline.cs Adds a post-download SHA256 verification pipeline.
src/c#/GeneralUpdate.Core/Download/Models/DownloadAsset.cs Adds download asset/plan records.
src/c#/GeneralUpdate.Core/Download/Executors/OssDownloadExecutor.cs Adds a simple OSS (signed URL) HTTP download executor.
src/c#/GeneralUpdate.Core/Download/Abstractions/PacketDTO.cs Adds packet/version request/response DTOs for server contracts.
src/c#/GeneralUpdate.Core/Download/Abstractions/IDownloadSource.cs Adds download source + post-processing pipeline interfaces.
src/c#/GeneralUpdate.Core/Configuration/HubConfig.cs Adds HubConfig settings container.
src/c#/GeneralUpdate.Core/Configuration/DiffMode.cs Adds DiffMode enum (Serial/Parallel).
src/c#/GeneralUpdate.Core/Configuration/BlackListConfig.cs Adds blacklist config record with Empty/HasRules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
public override void Execute()
{
GeneralTracer.Info("MacStrategy: executing macOS update");
Comment on lines +19 to +24
var mainApp = Path.Combine(_configinfo.InstallPath, _configinfo.MainAppName);
if (File.Exists(mainApp))
{
GeneralTracer.Info($"MacStrategy: starting {mainApp}");
Process.Start(mainApp);
}
Comment on lines +27 to +28
_onCompleted?.Invoke(null!); // result will be set by caller
}
private static async Task<string> ComputeSha256Async(string path, CancellationToken token)
{
using var sha = SHA256.Create();
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
Comment on lines +35 to +45
while ((read = await stream.ReadAsync(buffer, 0, buffer.Length, token)) > 0)
{
await fs.WriteAsync(buffer, 0, read, token);
downloaded += read;
var pct = total > 0 ? (double)downloaded / total * 100 : -1;
progress?.Report(new DownloadProgress(
Path.GetFileName(destPath), downloaded, total > 0 ? total : null, pct, DownloadStatus.Downloading));
}
sw.Stop();
progress?.Report(new DownloadProgress(Path.GetFileName(destPath), downloaded, total > 0 ? total : null, 100, DownloadStatus.Completed));
return new DownloadResult(url, destPath, downloaded, sw.Elapsed, 0, true, null);
Comment on lines +27 to +37
using var response = await _client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token);
response.EnsureSuccessStatusCode();
var total = response.Content.Headers.ContentLength ?? -1;
using var fs = new FileStream(destPath, FileMode.Create);
using var stream = await response.Content.ReadAsStreamAsync();
var buffer = new byte[8192];
long downloaded = 0;
int read;
while ((read = await stream.ReadAsync(buffer, 0, buffer.Length, token)) > 0)
{
await fs.WriteAsync(buffer, 0, read, token);
Comment on lines +9 to +22
public record PacketDTO
{
public string? Name { get; set; }
public string? Hash { get; set; }
public DateTime? ReleaseDate { get; set; }
public string? Url { get; set; }
public string? Version { get; set; }
public int? AppType { get; set; }
public int? Platform { get; set; }
public string? ProductId { get; set; }
public bool? IsForcibly { get; set; }
public bool? IsFreeze { get; set; }
public string? Format { get; set; }
public long Size { get; set; }
Comment on lines +21 to +27
public string? Format { get; set; }
public long Size { get; set; }
public string? FromVersion { get; set; }
public bool? IsCrossVersion { get; set; }
public string? MinClientVersion { get; set; }
public string? SourceArchiveHash { get; set; }
public string? TargetArchiveHash { get; set; }
Comment on lines +3 to +4
using System.Threading;
using System.Threading.Tasks;
…porter, etc.

- PacketDTO: nullable Size, remove unused usings
- DownloadProgressReporter: remove null!, safer callback design
- DefaultDownloadPipeline: FileShare.Read
- OssDownloadExecutor: throttling + ConfigureAwait + create dest dir
- MacStrategy: BuildPipeline + error handling
@JusterZhu
JusterZhu merged commit 5a6613a into master May 24, 2026
@JusterZhu
JusterZhu deleted the feat/missing-types branch May 24, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gap fill 1: Missing types — DiffMode, HubConfig, BlackListConfig, DownloadAsset, PacketDTO, MacStrategy, etc.

2 participants